package cn.lonecloud.action.product;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.lonecloud.model.Product;
import cn.lonecloud.service.ProductService;
import cn.lonecloud.service.impl.ProductServiceImpl;
import cn.lonecloud.util.ServletUtils;

/**
 * @author lonecloud
 * 显示商品信息
 */
@WebServlet("/productInfo")
public class ProductInfoServlet extends HttpServlet {
	
	ProductService productService=new ProductServiceImpl();

	/**
	 * 
	 */
	private static final long serialVersionUID = 7239587606119744694L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String idStr = req.getParameter("id");
		int id = 0;
		if (idStr!=null) {
			id=Integer.parseInt(idStr);
		}
		Product product=productService.findById(id);
		req.setAttribute("product", product);
		ServletUtils.forwardUrl(req, resp, "/product/changeProduct.jsp");
	}
}
